<template>
  <BeautyHeader title="美业快讯"/>
  <div class="beauty-banner">
    <img src="../../assets/images/banner1.jpg"/>
  </div>
  <van-list v-model:loading="loading" :finished="finished" finished-text="没有更多了" @load="onLoad">
    <div class="beauty-item" v-for="item in list" :key="item.id">
      <img :src="item.image"/>
      <div class="beauty-item-desc">
        <p>{{ item.title }}</p>
        <span>{{ item.descs }}</span>
      </div>
    </div>
  </van-list>

</template>

<script setup lang="ts">
import BeautyHeader from '@/components/PubHeaderComponent.vue'
import {ref} from "vue";
import {getBeauty} from "@/api/Home/home.ts";

interface IList {
  id: number,
  image: any,
  title: string,
  descs: string,
}

const loading = ref<boolean>(false)
const finished = ref<boolean>(false)
const list = ref<IList[]>([])
const page = ref<number>(1)
const onLoad = () => {
  getBeauty({
    page: page.value
  }).then(res => {
    loading.value = false
    if (res.status === 200) {
      page.value++
      list.value = list.value.concat(res.data)
    } else if (res.status === 500) {
      loading.value = false
    finished.value = true
    }
  })
}
</script>


<style scoped lang="less">
.beauty-banner {
  img {
    width: 100%;
  }
}

.beauty-item {
  display: flex;
  background-color: #fff;
  padding: 10px;
  box-sizing: border-box;
  border-bottom: 1px solid #f3f4f5;

  img {
    width: 100px;
    height: 100px;
    border-radius: 5px;
  }
  .beauty-item-desc{
    display: flex;
    flex-direction: column;
    justify-content:center;
    padding: 10px;
    box-sizing: border-box;
    p{
      font-size: 15px;
      padding: 10px 0;
    }
    span{
      display: block;
      font-size: 14px;
      color: #999;
      padding: 10px 0;
    }
  }
}
</style>